package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 */
//公共类
public class BaseDao {

    public static int execute(Connection connection, String sql, Object[]params, PreparedStatement preparedStatement){
        int upRows = 0;
        try {
            preparedStatement = connection.prepareStatement(sql);
            for (int i=0;i<params.length;i++){
                preparedStatement.setObject(i+1,params[i]);
            }
             upRows = preparedStatement.executeUpdate();

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return upRows;
    }
}
